package dobest.ray.com.jiongjiong.activity.action;

import android.content.Context;

import com.android.volley.VolleyError;
import com.dobest.ray.corelibs.logic.BaseLogic;
import com.dobest.ray.corelibs.utils.ToastMgr;

import java.util.ArrayList;
import java.util.List;

import dobest.ray.com.jiongjiong.R;
import dobest.ray.com.jiongjiong.activity.Presenter;
import dobest.ray.com.jiongjiong.activity.action.selftest.TestResultActivity;
import dobest.ray.com.jiongjiong.bean.BaseData;
import dobest.ray.com.jiongjiong.bean.BusinessCircleListBean;
import dobest.ray.com.jiongjiong.bean.PresenterData;
import dobest.ray.com.jiongjiong.bean.SelfTestDataBean;
import dobest.ray.com.jiongjiong.callback.PresenterCallBack;
import dobest.ray.com.jiongjiong.logicCache.cacheBaseLogic.ActionManager;

/**
 * Created by Administrator on 2016/3/10.
 */
public class ActionPresenter extends Presenter {
    private ActionManager manager;

    public ActionPresenter(PresenterCallBack callBack) {
        this.callback = callBack;
        manager = new ActionManager();
    }

    public void getSelfTestVisionData(final Context c, String uid, String uploadType, String downloadType, String valueL, String valueR) {
        manager.getSelfTestVisionData(c, uid, uploadType, downloadType, valueL, valueR, new BaseLogic.NListener<BaseData>() {
            @Override
            public void onResponse(BaseData data) {
                SelfTestDataBean bean = null;
                if (data.errorCode == 1) {
                    bean = data.data.saveAndGetVisionTestDataBySelf;
                }
                if (callback != null) {
                    callback.callBackPresenter(new PresenterData<SelfTestDataBean>(TestResultActivity.TEST_RESULT_DATA_TAG, bean));
                }

            }

            @Override
            public void onErrResponse(VolleyError error) {
                ToastMgr.show(c.getResources().getText(R.string.common_net_work_error));
            }
        });
    }

    /**
     * 获取服务里面的标签
     */
    public void getServiceLabels(Context context, int flag) {
        switch (flag) {
            case 0:
                // 配镜
//                manager.getCouponsBusinessCircleList(c, new NListener<BaseData>() {
//
//                    @Override
//                    public void onResponse(BaseData data) {
//                        List<BusinessCircleListBean> circleTypeList = null;
//                        if (data.status == 0) {
//                            circleTypeList = data.data.circleTypeList;
//                        }
//                        sendData(new PresenterData<List<BusinessCircleListBean>>("Label", circleTypeList));
//
//                    }
//
//                    @Override
//                    public void onErrResponse(VolleyError error) {
//                        ToastMgr.show("网络连接出错");
//                        sendData(new PresenterData<List<BusinessCircleListBean>>("Label", null));
//
//                    }
//
//                    @Override
//                    public void onAllPageLoaded(int nowPage, int totalPage) {
//                        // TODO Auto-generated method stub
//
//                    }
//                });
                List<BusinessCircleListBean> circleTypeList =new ArrayList<>();

                circleTypeList.add(new BusinessCircleListBean("武汉青少年视力防预中心"));
                circleTypeList.add(new BusinessCircleListBean("武汉青少年视力防预中心"));
                circleTypeList.add(new BusinessCircleListBean("武汉青少年视力防预中心"));
                circleTypeList.add(new BusinessCircleListBean("武汉青少年视力防预中心"));
                sendData(new PresenterData<List<BusinessCircleListBean>>("Label", circleTypeList));
                break;
            case 1:
//                manager.getCouponsTypeList(c, new BaseLogic.NListener<BaseData>() {
//
//                    @Override
//                    public void onResponse(BaseData data) {
//                        List<BusinessCircleListBean> couponTypeList = null;
//                        if (data.status == 0) {
//                            couponTypeList = data.data.couponTypeList;
//                        }
//                        sendData(new PresenterData<List<BusinessCircleListBean>>("Label", couponTypeList));
//                    }
//
//                    @Override
//                    public void onErrResponse(VolleyError error) {
//                        ToastMgr.show("网络连接出错");
//                        sendData(new PresenterData<List<BusinessCircleListBean>>("Label", null));
//
//                    }
//
//                    @Override
//                    public void onAllPageLoaded(int nowPage, int totalPage) {
//
//                    }
//                });
                List<BusinessCircleListBean> nearList =new ArrayList<>();

                nearList.add(new BusinessCircleListBean("武汉青少年视力防预中心最近",0));
                nearList.add(new BusinessCircleListBean("武汉青少年视力防预中心最近",0));
                nearList.add(new BusinessCircleListBean("武汉青少年视力防预中心最近",0));
                nearList.add(new BusinessCircleListBean("武汉青少年视力防预中心最近",0));
                nearList.add(new BusinessCircleListBean("武汉青少年视力防预中心最近",0));

                sendData(new PresenterData<List<BusinessCircleListBean>>("Label", nearList));

                break;
            case 2:
                // 定死的，所以直接写了
                List<BusinessCircleListBean> moneyType = new ArrayList<BusinessCircleListBean>();
                moneyType.add(new BusinessCircleListBean(0));
                moneyType.add(new BusinessCircleListBean(1));
                moneyType.add(new BusinessCircleListBean(2));
                moneyType.add(new BusinessCircleListBean(3));
                moneyType.add(new BusinessCircleListBean(4));
                moneyType.add(new BusinessCircleListBean(5));
                sendData(new PresenterData<List<BusinessCircleListBean>>("Label", moneyType));
                break;

            default:
                break;
        }

    }

}
